fix: crash on Windows MSYS2 UCRT env when executing command#2826
Open
mindfulcoder wants to merge 4 commits intoQwenLM:mainfrom
Open
fix: crash on Windows MSYS2 UCRT env when executing command#2826mindfulcoder wants to merge 4 commits intoQwenLM:mainfrom
mindfulcoder wants to merge 4 commits intoQwenLM:mainfrom
Conversation
wenshao
requested changes
Apr 5, 2026
wenshao
requested changes
Apr 5, 2026
wenshao
requested changes
Apr 5, 2026
Fix process crash when running Qwen Code in MSYS2 UCRT environment on Windows. The issue was caused by findGitBashPath() incorrectly selecting MSYS2's bash instead of Git Bash, which is incompatible with Windows ConPTY. Changes: - Add isRunningInMSYS2() and isRunningInGitBash() detection functions - Use system default shell (cmd.exe) in MSYS2 environments - Disable node-pty in MSYS2 to avoid ConPTY crashes - Add unit tests for environment detection Fixes QwenLM#2306 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
…n bash env check;2. restore the logic for checking git bash env to keep compatibility.
b7b2522 to
10da38b
Compare
mindfulcoder
commented
Apr 7, 2026
mindfulcoder
commented
Apr 7, 2026
- Convert isRunningInMSYS2 mock to hoisted variable to allow runtime control - Add test case verifying child_process fallback when running in MSYS2 environment - Ensure PTY is skipped and child_process is used directly in MSYS2 even when shouldUseNodePty is true Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
mindfulcoder
commented
Apr 7, 2026
mindfulcoder
commented
Apr 7, 2026
mindfulcoder
commented
Apr 7, 2026
mindfulcoder
commented
Apr 7, 2026
mindfulcoder
commented
Apr 7, 2026
wenshao
reviewed
Apr 7, 2026
wenshao
requested changes
Apr 7, 2026
wenshao
added a commit
that referenced
this pull request
Apr 7, 2026
Two issues found from real review (PR #2826): 1. Multiple /review runs on same PR create duplicate comments. Now Step 9 checks for existing "via Qwen Code /review" comments before posting and warns the user about potential duplicates. 2. Comments posted without line numbers appear as orphaned PR comments. Now enforced: every inline comment MUST reference a specific line in the diff. Findings that can't be mapped to diff lines go in the summary instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
DennisYu07
approved these changes
Apr 10, 2026
| export const isWindows = () => os.platform() === 'win32'; | ||
|
|
||
| /** | ||
| * 检测当前是否运行在 MSYS2 环境中 |
Collaborator
There was a problem hiding this comment.
please do not use Chinese annotation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix process crash when running Qwen Code in MSYS2 UCRT environment on Windows. The issue was caused by findGitBashPath() incorrectly selecting MSYS2's bash instead of Git Bash, which is incompatible with Windows ConPTY.
Changes:
Fixes #2306
TLDR
Problem: Qwen Code crashes when executing system commands on Windows MSYS2 UCRT environments (UCRT64, CLANG64, MSYS).
Root Cause: The
findGitBashPath()function introduced in commitc2fe554e3incorrectly selects MSYS2's bundled bash instead of Git Bash. MSYS2 bash is designed for the MSYS2 POSIX emulation layer and is incompatible with Windows ConPTY (used by node-pty), causing immediate crashes.Solution:
isRunningInMSYS2(),isRunningInGitBash()) to distinguish between MSYS2 and Git Bash environments using theMSYSTEMenvironment variableComSpec) instead of bash - reverting to v0.11.1's working behaviorMINGW64,MINGW32), continue usingfindGitBashPath()to locate Git Bash correctlyFiles Changed:
packages/core/src/utils/shell-utils.ts- Added detection functions and refactoredgetShellConfiguration()packages/core/src/services/shellExecutionService.ts- Disable node-pty in MSYS2packages/core/src/utils/shell-utils.test.ts- Added unit tests for new detection functionsScreenshots / Video Demo
N/A
Dive Deeper
Environment Variable Analysis
MSYSTEMUCRT64MINGW64MINGW_PREFIX/ucrt64/mingw64MSYSTEM_PREFIX/ucrt64/mingw64Detection Logic
MSYSTEM === 'MSYS'or starts withUCRT/CLANGComSpec)MSYSTEM.startsWith('MINGW')orTERMcontainscygwinfindGitBashPath())Why This Fix Works
c2fe554e3, MSYS2 environments worked correctly because they used the system default shellfindGitBashPath()fix for users who have Git Bash installedReviewer Test Plan
MSYS2 UCRT64 environment (primary fix validation):
qwenand execute any shell command (e.g.,ls,pwd,echo test)Git Bash environment (regression test):
qwenand execute shell commandsStandard Windows environments (regression test):
qwenand verify commands workqwenand verify commands workRun unit tests:
npm run test -- packages/core/src/utils/shell-utils.test.tsisRunningInMSYS2, 8 forisRunningInGitBash)Type checking:
Testing Matrix
Notes:
Linked issues / bugs
Fixes #2306